﻿using System.Collections.Generic;

namespace CommonUtils
{
    /// <summary>
    /// 键值对 Dictionary key不可为空，value可以为空
    /// </summary>
    public class Map<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public Map() { }

        public Map(Dictionary<TKey, TValue> dictionary) : base(dictionary) { }

        public Map(TKey key, TValue value)
        => Add(key, value);

        public void Fill(Dictionary<TKey, TValue> dictionary)
        {
            foreach (var pair in dictionary)
                this[pair.Key] = pair.Value;
        }

        public KeyValuePair<TKey, TValue>[] GetKeyValueArray()
        {
            return this.ToArray<KeyValuePair<TKey, TValue>>();
        }
    }
}
